package com.partition.mysql.constant;

/**
 * 公用sql模板
 *
 * @author hexinglin
 * @created 2022-04-08 16:40
 **/
public class SqlConstant {
    /*
    * 查找表的所有分区
    */
    public static String FIND_TABLE_PARTITION = "SELECT * FROM information_schema.PARTITIONS a WHERE a.table_name IN ('%s')ORDER BY partition_ordinal_position DESC;";

    /*
    * 对分区字段增加联合主键索引
    */
    public static String ALTER_PRIMARY_KEY = "ALTER TABLE `%s` DROP PRIMARY KEY, ADD PRIMARY KEY(`id`,`%s`);";

    /*
     * 初始化表格第一个分区
     */
    public static String DEFAULT_PARTITION_BY = "alter TABLE %s  PARTITION BY range columns(%s)(%s);";

    /*
     * 表格后续增加分区
     */
    public static String ADD_PARTITION_BY = "ALTER TABLE %s ADD PARTITION (%s);";

    /*
     * 表格后续删除分区,多个分区用逗号分隔
     */
    public static String DELETE_PARTITION_BY = "ALTER TABLE %s  DROP PARTITION %s";


    /*分区基础单元语句*/
    public static String PARTITION_BASIC_STRPARTI =  "partition p%s VALUES less than (%d)";
}
